#ifndef STX_BIT_CAST_HPP
#define STX_BIT_CAST_HPP

#include <cstring>

namespace stx {

template <class Src, class Dst>
inline Dst bit_cast(const Src& src)
{
    // Compile time assertion: sizeof(Dest) == sizeof(Source)
    // A compile error here means your Src and Dst have different sizes.
    typedef char verify_sizes_are_equal[sizeof(Dst) == sizeof(Src) ? 1 : -1];
    Dst dst;
    std::memcpy(&dst, &src, sizeof(dst));
    return dst;
}

} // namespace stx

#endif // STX_BIT_CAST_HPP
